import { createWebHashHistory, createRouter } from 'vue-router';

import Layout from '../views/Main.vue';
import Login from '../views/Login/index.vue';

const localData=localStorage.getItem('pz_v3pz');

const routes=[
    {
        path: '/',
        component: Layout,
        name: 'main',
        redireact:to=>{
            if(localData){
                const child=JSON.parse(localData).menu.routerList[0].children;
                if(child.length){
                    return child[0].meta.path;
                }else{
                    return JSON.parse(localData).menu.routerList[0].meta.path;
                }
            }else{
                return '/login';
            }
        },
        children: []
    },
    {
        name:'login',
        path: '/login',
        component: Login
    },
]

const router=createRouter({
    history: createWebHashHistory(),
    routes,
})

export default router;